package io.renren.controller;

import io.renren.constant.AppConstant;
import io.renren.entity.AppFeedbackEntity;
import io.renren.service.AppFeedbackService;
import io.renren.vo.RespModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * @author rdawnx
 * @package_name io.renren.controller
 * @class_name AppFeedbackController.java
 * @author_email rdawnxhi@163.com
 * @JDK_version 1.8
 * @create_on 2019/07/30 14:46
 */
@RestController
@RequestMapping("/feedback")
public class AppFeedbackController {

    @Autowired
    private AppFeedbackService appFeedbackService;

    @PostMapping(value = "/submit", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "提交意见和建议", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
    @com.cxytiandi.encrypt.springboot.annotation.Decrypt
    @com.cxytiandi.encrypt.springboot.annotation.Encrypt
    public RespModel<String> submit(@RequestBody AppFeedbackEntity entity) {
        entity.setCreateTime(new Date());
        appFeedbackService.save(entity);
        return new RespModel().getRespModelInstance(AppConstant.STATU_SUCCESS, null, null);
    }
}
